/**
 * Copyright (c) 2018-2023, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Contains: Condition variable
 * 
 * Change Logs:
 * Date           Author            Notes
 * 2023-08-25     JasonHu           Init
 */

#ifndef __XBOOK_CONDITION__
#define __XBOOK_CONDITION__

#include <nxos_mini.h>
#include <base/list.h>
#include <base/spin.h>
#include <base/clock.h>
#include <base/waitqueue.h>

struct NX_Condition
{
    NX_WaitQueue condWaitQueue;
    NX_Spin spinLock;
};
typedef struct NX_Condition NX_Condition;

NX_Error NX_ConditionInit(NX_Condition *condition, NX_U32 attr);
NX_Condition *NX_ConditionCreate(NX_U32 attr);
NX_Error NX_ConditionDestroy(NX_Condition *condition);
NX_Error NX_ConditionWait(NX_Condition *condition, NX_Mutex *mutex);
NX_Error NX_ConditionWaitTimeout(NX_Condition *condition, NX_Mutex *mutex, NX_TimeVal tv);
NX_Error NX_ConditionSignal(NX_Condition *condition);
NX_Error NX_ConditionBroadcast(NX_Condition *condition);

#endif /* __XBOOK_CONDITION__ */
